//
//  WGQTransfersRecordsTableViewCell.m
//  meiang_edu
//
//  Created by gq w on 2018/9/26.
//  Copyright © 2018年 com.meiang.meiang_edu. All rights reserved.
//

#import "WGQTransfersRecordsTableViewCell.h"
#import "WGQTransfersRecordsModel.h"

@interface WGQTransfersRecordsTableViewCell ()

@property (nonatomic,strong) UIView * backView;

//送出
@property (nonatomic,strong) UIImageView * sendOutImageView;
@property (nonatomic,strong) UILabel * sendOutNameLabel;
@property (nonatomic,strong) UILabel * sendOutSubLabel;
@property (nonatomic,strong) UILabel * sendOutTimeLabel;
@property (nonatomic,strong) UIImageView * sendOutRightImageView;
@property (nonatomic,strong) UILabel * sendOutRightLabel;
@property (nonatomic,strong) UIView * sendOutLineView;

//接入
@property (nonatomic,strong) UIImageView * accessImageView;
@property (nonatomic,strong) UILabel * accessNameLabel;
@property (nonatomic,strong) UILabel * accessSubLabel;
@property (nonatomic,strong) UILabel * accessTimeLabel;
@property (nonatomic,strong) UIImageView * accessRightImageView;
@property (nonatomic,strong) UILabel * accessRightLabel;
@property (nonatomic,strong) UIView * accessLineView;

@end

@implementation WGQTransfersRecordsTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        [self addSubViews];
    }
    return self;
}

- (void)addSubViews
{
    self.backView = [[UIView alloc] init];
    self.backView.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:self.backView];
    [self.backView mas_makeConstraints:^(MASConstraintMaker *make)
    {
        make.edges.equalTo(self.contentView);
    }];
    
    //送出
    self.sendOutImageView = [[UIImageView alloc] init];
    [self.backView addSubview:self.sendOutImageView];
    [self.sendOutImageView mas_makeConstraints:^(MASConstraintMaker *make)
    {
        make.left.equalTo(self.backView.mas_left).offset(12 * kScale);
        make.top.equalTo(self.backView.mas_top).offset(12 * kScale);
        make.width.and.height.mas_equalTo(40 * kScale);
    }];
    
    self.sendOutNameLabel = [[UILabel alloc] init];
    self.sendOutNameLabel.textColor = FFColor(0x333333);
    self.sendOutNameLabel.font = [UIFont fontWithName:kMainFontFormat size:14 * kScale];
    self.sendOutNameLabel.textAlignment = NSTextAlignmentLeft;
    [self.backView addSubview:self.sendOutNameLabel];
    [self.sendOutNameLabel mas_makeConstraints:^(MASConstraintMaker *make)
    {
        make.left.equalTo(self.sendOutImageView.mas_right).offset(12 * kScale);
        make.top.equalTo(self.sendOutImageView.mas_top).offset(2 * kScale);
    }];
    
    self.sendOutSubLabel = [[UILabel alloc] init];
    self.sendOutSubLabel.textColor = FFColor(0x999999);
    self.sendOutSubLabel.font = [UIFont fontWithName:kMainFontFormat size:12 * kScale];
    self.sendOutSubLabel.textAlignment = NSTextAlignmentLeft;
    [self.backView addSubview:self.sendOutSubLabel];
    [self.sendOutSubLabel mas_makeConstraints:^(MASConstraintMaker *make)
    {
        make.left.equalTo(self.sendOutNameLabel.mas_left);
        make.top.equalTo(self.sendOutNameLabel.mas_bottom).offset(2 * kScale);
    }];
    
    self.sendOutTimeLabel = [[UILabel alloc] init];
    self.sendOutTimeLabel.textColor = FFColor(0x999999);
    self.sendOutTimeLabel.font = [UIFont fontWithName:kMainFontFormat size:10 * kScale];
    self.sendOutTimeLabel.textAlignment = NSTextAlignmentLeft;
    [self.backView addSubview:self.sendOutTimeLabel];
    [self.sendOutTimeLabel mas_makeConstraints:^(MASConstraintMaker *make)
    {
        make.left.equalTo(self.sendOutImageView.mas_left);
        make.top.equalTo(self.sendOutImageView.mas_bottom).offset(12 * kScale);
    }];
    
    self.sendOutLineView = [[UIView alloc] init];
    self.sendOutLineView.backgroundColor = FFColor(0x999999);
    [self.backView addSubview:self.sendOutLineView];
    [self.sendOutLineView mas_makeConstraints:^(MASConstraintMaker *make)
    {
        make.left.equalTo(self.sendOutImageView.mas_left);
        make.right.equalTo(self.backView.mas_right).offset(-12 * kScale);
        make.top.equalTo(self.sendOutTimeLabel.mas_bottom).offset(12 * kScale);
        make.height.mas_equalTo(1);
    }];
    
    self.sendOutRightImageView = [[UIImageView alloc] init];
    self.sendOutRightImageView.image = [UIImage imageNamed:@"Send"];
    [self.backView addSubview:self.sendOutRightImageView];
    [self.sendOutRightImageView mas_makeConstraints:^(MASConstraintMaker *make)
    {
        make.width.and.height.mas_equalTo(30 * kScale);
        make.top.equalTo(self.backView.mas_top).offset(30 * kScale);
        make.right.equalTo(self.backView.mas_right).offset(-54 * kScale);
    }];
    
    self.sendOutRightLabel = [[UILabel alloc] init];
    self.sendOutRightLabel.textColor = FFColor(0x00aed0);
    self.sendOutRightLabel.font = [UIFont fontWithName:kMainFontFormat size:12 * kScale];
    self.sendOutRightLabel.textAlignment = NSTextAlignmentRight;
    self.sendOutRightLabel.text = @"送出";
    [self.backView addSubview:self.sendOutRightLabel];
    [self.sendOutRightLabel mas_makeConstraints:^(MASConstraintMaker *make)
    {
        make.left.equalTo(self.sendOutRightImageView.mas_right).offset(12 * kScale);
        make.centerY.equalTo(self.sendOutRightImageView.mas_centerY);
    }];
    
    //接入
    self.accessImageView = [[UIImageView alloc] init];
    [self.backView addSubview:self.accessImageView];
    [self.accessImageView mas_makeConstraints:^(MASConstraintMaker *make)
    {
        make.left.equalTo(self.backView.mas_left).offset(12 * kScale);
        make.top.equalTo(self.sendOutLineView.mas_bottom).offset(12 * kScale);
        make.width.and.height.mas_equalTo(40 * kScale);
    }];
    
    self.accessNameLabel = [[UILabel alloc] init];
    self.accessNameLabel.textColor = FFColor(0x333333);
    self.accessNameLabel.font = [UIFont fontWithName:kMainFontFormat size:14 * kScale];
    self.accessNameLabel.textAlignment = NSTextAlignmentLeft;
    [self.backView addSubview:self.accessNameLabel];
    [self.accessNameLabel mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.left.equalTo(self.accessImageView.mas_right).offset(12 * kScale);
         make.top.equalTo(self.accessImageView.mas_top).offset(2 * kScale);
     }];
    
    self.accessSubLabel = [[UILabel alloc] init];
    self.accessSubLabel.textColor = FFColor(0x999999);
    self.accessSubLabel.font = [UIFont fontWithName:kMainFontFormat size:12 * kScale];
    self.accessSubLabel.textAlignment = NSTextAlignmentLeft;
    [self.backView addSubview:self.accessSubLabel];
    [self.accessSubLabel mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.left.equalTo(self.accessNameLabel.mas_left);
         make.top.equalTo(self.accessNameLabel.mas_bottom).offset(2 * kScale);
     }];
    
    self.accessTimeLabel = [[UILabel alloc] init];
    self.accessTimeLabel.textColor = FFColor(0x999999);
    self.accessTimeLabel.font = [UIFont fontWithName:kMainFontFormat size:10 * kScale];
    self.accessTimeLabel.textAlignment = NSTextAlignmentLeft;
    [self.backView addSubview:self.accessTimeLabel];
    [self.accessTimeLabel mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.left.equalTo(self.accessImageView.mas_left);
         make.top.equalTo(self.accessImageView.mas_bottom).offset(12 * kScale);
     }];
    
    self.accessLineView = [[UIView alloc] init];
    self.accessLineView.backgroundColor = FFColor(0x999999);
    [self.backView addSubview:self.accessLineView];
    [self.accessLineView mas_makeConstraints:^(MASConstraintMaker *make)
    {
        make.left.equalTo(self.accessImageView.mas_left);
        make.right.equalTo(self.backView.mas_right).offset(-12 * kScale);
        make.height.mas_equalTo(1);
        make.bottom.equalTo(self.backView.mas_bottom);
    }];
    
    self.accessRightImageView = [[UIImageView alloc] init];
    self.accessRightImageView.image = [UIImage imageNamed:@"insert"];
    [self.backView addSubview:self.accessRightImageView];
    [self.accessRightImageView mas_makeConstraints:^(MASConstraintMaker *make)
    {
        make.width.and.height.mas_equalTo(30 * kScale);
        make.top.equalTo(self.backView.mas_top).offset(120 * kScale);
        make.right.equalTo(self.backView.mas_right).offset(-54 * kScale);
    }];
    
    self.accessRightLabel = [[UILabel alloc] init];
    self.accessRightLabel.textColor = FFColor(0xff9000);
    self.accessRightLabel.font = [UIFont fontWithName:kMainFontFormat size:12 * kScale];
    self.accessRightLabel.textAlignment = NSTextAlignmentRight;
    self.accessRightLabel.text = @"接入";
    [self.backView addSubview:self.accessRightLabel];
    [self.accessRightLabel mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.left.equalTo(self.accessRightImageView.mas_right).offset(12 * kScale);
         make.centerY.equalTo(self.accessRightImageView.mas_centerY);
     }];
}

- (void)setObject:(id)object
{
    if ([object isKindOfClass:[WGQTransfersRecordsModel class]])
    {
        WGQTransfersRecordsModel * model = object;
        //送出
        //model.fa_useriamge
        [self.sendOutImageView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",IMG_OSS,model.fa_useriamge]]];
        self.sendOutNameLabel.text = model.fa_username;
        self.sendOutSubLabel.text = model.cnotes;
        self.sendOutTimeLabel.text = model.sender_time;
        
        //接入
        //model.org_userimage
        [self.accessImageView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",IMG_OSS,model.org_userimage]]];
        self.accessNameLabel.text = model.or_username;
        self.accessSubLabel.text = model.us_orgname;
        self.accessTimeLabel.text = model.attime;
    }
}

- (void)awakeFromNib
{
    [super awakeFromNib];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];
}

@end
